<template>
	<view class="page-footer-wrap">
		<u-tabbar :value="current" inactiveColor="#000000" activeColor="#2172B1" @change="toggleTab" :border="false"
			:fixed="true" :placeholder="true" :safeAreaInsetBottom="true">


			<!-- :icon="current == item.title ? item.icon1 :item.icon" -->
			<u-tabbar-item v-for="(item,index) in tabbarList" :key="index" :text="item.title" :name="item.title"
				:class="{active: current == item.title}">
				<image class="u-page__item__slot-icon" slot="active-icon" :src="item.icon1"></image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" :src="item.icon"></image>
			</u-tabbar-item>

			<!-- 	<u-tabbar-item text="日程" name="日程" :class="{active: current == '日程'}">
			</u-tabbar-item>
			<u-tabbar-item text="房间" name="房间" :class="{active: current == '房间'}">
			</u-tabbar-item>
			<u-tabbar-item text="就餐" name="就餐" :class="{active: current == '就餐'}">
			</u-tabbar-item> -->
		</u-tabbar>
	</view>
</template>

<script>
	export default {
		props: {
			current: {
				default: '其它'
			},
		},
		data() {
			return {
				tabbarList: [{
						title: '首页',
						route: '/index',
						icon: require('@/static/tabbar/tab1.png'),
						icon1: require('@/static/tabbar/tab1-1.png')
					},
					{
						title: '我的',
						route: '/my',
						icon: require('@/static/tabbar/tab2.png'),
						icon1: require('@/static/tabbar/tab2-1.png')
					},
					// {
					// 	title: '路由',
					// 	route: '/routes',
					// 	icon: require('@/static/tabbar/tab2.png'),
					// 	icon1: require('@/static/tabbar/tab2-1.png')
					// },
				]
			}
		},
		created() {},
		methods: {
			toggleTab(name) {
				// let uid = uni.getStorageSync('uid');
				let item = this.tabbarList.find(v => v.title == name)
				console.warn('toggleTab', name)
				console.warn('toggleTab', {
					...item
				})

				console.warn('is_yiyanzheng', this.is_yiyanzheng)


				if (item.title == '房间' || item.title == '就餐') {
					if (!this.is_yiyanzheng) {
						this.$alert('请您先验证参会资格')
						return
					}

					if (!this.is_qiandao) {
						this.$alert('请您先在首页点击签到')
						return
					}
				}


				if (item.title == '就餐') {
					//扫一扫
					this.toYongshan()
				} else {
					this.toRoute(item.route)
				}

			},

			toYongshan() {
				// this.toRoute('/qiandao')
				// 只允许通过相机扫码
				let that = this;
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						console.log('扫码结果', res);
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						//查询扫码状态
				

						let type = 1;
						that.toRoute({
							path: '/jiucan',
							query: {
								type: type, //成功1  警告 2  错误3 
								scanresult: res.result,
							}
						})
					}
				});
			},

		}
	}
</script>

<style lang="scss" scoped>
	.page-footer-wrap {
		// position: relative;
		// z-index: 9999;
	}

	.u-page__item__slot-icon {
		width: 44rpx;
		height: 44rpx;
	}

	.u-tabbar-item__text {
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #9695A3;
	}


	::v-deep .u-tabbar-item.active {
		.u-tabbar-item__text {
			font-size: 32rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #000000;
		}
	}


	::v-deep .u-tabbar-item__icon .u-icon__img {
		width: min-content;
		height: 44rpx;
	}
</style>